<template>
  <el-breadcrumb separator="/">
    <el-breadcrumb-item
      v-for="(item, index) in breadcrumb"
      :key="index"
      @click="myClick(item)"
    >
      <h1 style="cursor:pointer;">{{item.text}}</h1>
    </el-breadcrumb-item>
  </el-breadcrumb>
</template>

<script>
  import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
  import { store } from '@naturefw/nf-state'
  // 加载选中的文档
  import mdController from '../service/md.js'
</script>

<script setup>

  // 当前菜单、文档内容，菜单列表
  const { current } = store

  const breadcrumb = current.breadcrumb
  const { loadDocById } = mdController()

  const myClick = (menu) => {
    loadDocById(menu.menuId, current.ver)
      .then((res) => {
        // 找到了文档
        Object.assign(current.docInfo, res)
      }).catch((res) => {
        // 没有文档
        Object.assign(current.docInfo, res)
      })
  }
</script>